package com.cloud.zipkin.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.sampler.AlwaysSampler;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.logging.Level;

/**
 * @Author Ldj
 * @Date 2018/3/10 14:04
 * @Description 数据处理
 */
@RestController
public class TestController {

    public static final Logger logger = LoggerFactory.getLogger(TestController.class);

    @Autowired
    private RestTemplate restTemplate;

    @Bean
    public RestTemplate getRestTemplate(){
        return new RestTemplate();
    }

    @Bean
    public AlwaysSampler defaultSampler(){
        return new AlwaysSampler();
    }

    @RequestMapping("/hi")
    public String callHome(){
        logger.info("calling trace service-hi 0");
        return restTemplate.getForObject("http://localhost:9413/miya", String.class);
    }

    @RequestMapping("/info")
    public String info(){
        logger.info("calling trace service-hi 1 ");
        return "i'm service-hi";
    }


}
